---
description: Column Presets
keywords:
  - hasura
  - docs
  - permissions
  - rules
  - column
  - presets
sidebar_position: 60
---

import Thumbnail from '@site/src/components/Thumbnail';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Column Presets

## Introduction

[//]: # (TODO delete http://localhost:3000/docs/latest/schema/postgres/default-values/column-presets/ and redirect it
here)
While this is not strictly a permission configuration, defining role-based column presets for `insert` and `update`
operations on any column automatically removes the ability to manually insert or update it for that role.

The respective fields will also be removed from the generated GraphQL schema for that role.

This setup very useful in avoiding sensitive user information being sent in the request and instead leveraging
session variables or static data for that information.

<Tabs groupId="user-preference" className="api-tabs">
<TabItem value="console" label="Console">

You can define column presets for either `insert` or `update` operations in the Hasura Console in **Data ->
[table] -> Permissions -> insert / update** as follows:

<Thumbnail src="/img/auth/set_column_preset_console_2.10.1.png" alt="Set column preset" width="1000px" />

</TabItem>
<TabItem value="cli" label="CLI">

You can define column presets for table columns in the `metadata > databases -> [database-name] -> tables -> 
[table-name].yaml`, eg: `public_users.yaml`:

```yaml {8-9}
table:
  name: users
  schema: public
insert_permissions:
  - role: user
    permission:
      check: {}
      set:
        id: x-hasura-User-Id
      columns:
        - id
```

Apply the Metadata by running:

```bash
hasura metadata apply
```

</TabItem>
<TabItem value="api" label="API">

You can define column presets with either the [insert](/api-reference/syntax-defs.mdx#insertpermission) or 
[update](/api-reference/syntax-defs.mdx#updatepermission)
[permissions Metadata API](/api-reference/metadata-api/permission.mdx). Example using a Postgres db:

```http {15-20}
POST /v1/metadata HTTP/1.1
Content-Type: application/json
X-Hasura-Role: admin

{
  "type": "pg_create_insert_permission",
  "args": {
    "table": {
      "name": "users",
      "schema": "public"
    },
    "role": "user",
    "permission": {
      "check": {},
      "columns": [
        "id"
      ],
      "set": {
        "id": "x-hasura-user-id"
    }
  },
    "source": "default"
  }
}
```

</TabItem>
</Tabs>
